<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Test::Unit::TestCase</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Test::Unit::TestCase</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/interop/test/unit/testcase_rb.html">
                vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
This extension of the standard <a
href="TestCase.html">Test::Unit::TestCase</a> makes RSpec available from
within, so that you can do things like:
</p>
<p>
require &#8216;test/unit&#8217; require &#8216;spec&#8216;
</p>
<p>
class MyTest &lt; <a href="TestCase.html">Test::Unit::TestCase</a>
</p>
<pre>
  it &quot;should work with Test::Unit assertions&quot; do
    assert_equal 4, 2+1
  end

  def test_should_work_with_rspec_expectations
    (3+1).should == 5
  end
</pre>
<p>
end
</p>
<p>
See also <a
href="../../Spec/Example/ExampleGroup.html">Spec::Example::ExampleGroup</a>
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000629">example_method?</a>&nbsp;&nbsp;
      <a href="#M000631">new</a>&nbsp;&nbsp;
      <a href="#M000632">run</a>&nbsp;&nbsp;
      <a href="#M000628">suite</a>&nbsp;&nbsp;
      <a href="#M000630">test_method?</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name"><a href="../../Spec/Example/ExampleMethods.html">Spec::Example::ExampleMethods</a></span>
      </div>
    </div>

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000629" class="method-detail">
        <a name="M000629"></a>

        <div class="method-heading">
          <a href="#M000629" class="method-signature">
          <span class="method-name">example_method?</span><span class="method-args">(method_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000629-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000629-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb, line 34</span>
34:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">example_method?</span>(<span class="ruby-identifier">method_name</span>)
35:           <span class="ruby-identifier">should_method?</span>(<span class="ruby-identifier">method_name</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">test_method?</span>(<span class="ruby-identifier">method_name</span>)
36:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000631" class="method-detail">
        <a name="M000631"></a>

        <div class="method-heading">
          <a href="#M000631" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(defined_description, &amp;implementation)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000631-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000631-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb, line 46</span>
46:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">defined_description</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">implementation</span>)
47:         <span class="ruby-ivar">@_defined_description</span> = <span class="ruby-identifier">defined_description</span>
48:         
49:         <span class="ruby-comment cmt"># TODO - examples fail in rspec-rails if we remove &quot;|| pending_implementation&quot;</span>
50:         <span class="ruby-comment cmt">#      - find a way to fail without it in rspec's code examples</span>
51:         <span class="ruby-ivar">@_implementation</span> = <span class="ruby-identifier">implementation</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">pending_implementation</span>
52: 
53:         <span class="ruby-ivar">@_result</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Test</span><span class="ruby-operator">::</span><span class="ruby-constant">Unit</span><span class="ruby-operator">::</span><span class="ruby-constant">TestResult</span>.<span class="ruby-identifier">new</span>
54:         <span class="ruby-comment cmt"># @method_name is important to set here because it &quot;complies&quot; with Test::Unit's interface.</span>
55:         <span class="ruby-comment cmt"># Some Test::Unit extensions depend on @method_name being present.</span>
56:         <span class="ruby-ivar">@method_name</span> = <span class="ruby-ivar">@_defined_description</span>
57:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000628" class="method-detail">
        <a name="M000628"></a>

        <div class="method-heading">
          <a href="#M000628" class="method-signature">
          <span class="method-name">suite</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000628-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000628-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb, line 30</span>
30:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">suite</span>
31:           <span class="ruby-constant">Test</span><span class="ruby-operator">::</span><span class="ruby-constant">Unit</span><span class="ruby-operator">::</span><span class="ruby-constant">TestSuiteAdapter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
32:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000630" class="method-detail">
        <a name="M000630"></a>

        <div class="method-heading">
          <a href="#M000630" class="method-signature">
          <span class="method-name">test_method?</span><span class="method-args">(method_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000630-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000630-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb, line 38</span>
38:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">test_method?</span>(<span class="ruby-identifier">method_name</span>)
39:           <span class="ruby-identifier">method_name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^test[_A-Z]./</span> <span class="ruby-operator">&amp;&amp;</span> (
40:             <span class="ruby-identifier">instance_method</span>(<span class="ruby-identifier">method_name</span>).<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">||</span>
41:             <span class="ruby-identifier">instance_method</span>(<span class="ruby-identifier">method_name</span>).<span class="ruby-identifier">arity</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span>
42:           )
43:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000632" class="method-detail">
        <a name="M000632"></a>

        <div class="method-heading">
          <a href="#M000632" class="method-signature">
          <span class="method-name">run</span><span class="method-args">(ignore_this_argument=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000632-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000632-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb, line 59</span>
59:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">ignore_this_argument</span>=<span class="ruby-keyword kw">nil</span>)
60:         <span class="ruby-keyword kw">super</span>()
61:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>